import 'package:aio/aio.dart';
import 'package:app/src/http/url.dart';

///PageView首页通知栏
class CompanyNoticeInfo extends BaseBean {
  /// <summary>
  /// 公告编号
  /// </summary>
  String? NoticeId = "";

  /// <summary>
  /// 公告标题
  /// </summary>
  String? NoticeTitle = "";

  /// <summary>
  /// 公告内容
  /// </summary>
  String? NoticeContent = "";

  /// <summary>
  /// 公告类型
  /// </summary>
  String? NoticeClass = "";

  /// <summary>
  /// 添加日期
  /// </summary>
  String? AddDate = "";

  /// <summary>
  /// 添加用户
  /// </summary>
  String? UserId = "";

  /// <summary>
  /// 首页显示
  /// </summary>
  String? IsIndex = "";

  /// <summary>
  /// 滚动设置
  /// </summary>
  String? IsMarquee = "";

  /// <summary>
  /// 主题颜色
  /// </summary>
  String? FontSize = "";

  /// <summary>
  /// 主题颜色
  /// </summary>
  String? ThemeColor =
      ""; //		"ThemeColor": "FF649F", fixme 后台公告管理里可以设置，服务器默认返回的是 FFFFFF 白色。

  /// <summary>
  /// 开始日期
  /// </summary>
  String? StartDate = "";

  /// <summary>
  /// 结束日期
  /// </summary>
  String? EndDate = "";

  /// <summary>
  /// 公告图片
  /// </summary>
  String? NoticePicture = "";

  String? _NoticePicture = "";

  ///获取图片地址
  String? getNoticePictureUrl() {
    if (StringUtils.isEmpty(NoticePicture)) {
      return null;
    }
    if (StringUtils.isNotEmpty(_NoticePicture)) {
      return _NoticePicture;
    }
    //print("图片地址：$NoticePicture");
    //http://test.bwg2017.com/["/UploadFile/Notice/220907637981614938564765.jpg"]
    //http://test.bwg2017.com/[\"/UploadFile/Notice/220513637880281547492969.jpg\",\"/UploadFile/Notice/220513637880281547698047.jpg\",\"/UploadFile/Notice/220513637880281615266407.jpg\"]"
    if (NoticePicture!.contains("http")) {
      _NoticePicture = UrlUtils.parseUrl(NoticePicture, isEnable: true);
    } else {
      _NoticePicture =
          UrlUtils.parseUrl(Url.getFileUrl(NoticePicture), isEnable: true);
    }
    return _NoticePicture;
  }

  @override
  fromJson(Map<String, dynamic> json) {
    // TODO: implement fromJson
    NoticeId = json["NoticeId"]?.toString() ?? "";
    NoticeTitle = json["NoticeTitle"]?.toString() ?? "";
    NoticeContent = json["NoticeContent"]?.toString() ?? "";
    NoticeClass = json["NoticeClass"]?.toString() ?? "";
    AddDate = json["AddDate"]?.toString() ?? "";
    UserId = json["UserId"]?.toString() ?? "";
    IsIndex = json["IsIndex"]?.toString() ?? "";
    IsMarquee = json["IsMarquee"]?.toString() ?? "";
    FontSize = json["FontSize"]?.toString() ?? "";
    ThemeColor = json["ThemeColor"]?.toString() ?? "";
    StartDate = json["StartDate"]?.toString() ?? "";
    EndDate = json["EndDate"]?.toString() ?? "";
    NoticePicture = json["NoticePicture"]?.toString() ?? "";
  }

  @override
  instance() {
    // TODO: implement instance
    return CompanyNoticeInfo();
  }

  @override
  Map<String, dynamic> toJson() {
    // TODO: implement toJson
    var map = <String, dynamic>{};
    map["NoticeId"] = NoticeId;
    map["NoticeTitle"] = NoticeTitle;
    map["NoticeContent"] = NoticeContent;
    map["NoticeClass"] = NoticeClass;
    map["AddDate"] = AddDate;
    map["UserId"] = UserId;
    map["IsIndex"] = IsIndex;
    map["IsMarquee"] = IsMarquee;
    map["FontSize"] = FontSize;
    map["ThemeColor"] = ThemeColor;
    map["StartDate"] = StartDate;
    map["EndDate"] = EndDate;
    map["NoticePicture"] = NoticePicture;
    return map;
  }
}
